package com.eastfair.enums;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 语言环境枚举类
 *
 * </p>
 *
 * @author zjn
 * @date 2021-07-29
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "AuditStateEnum", description = "语言 #{CN:中文;EN:英文-枚举")
public enum AuditStateEnum implements BaseEnum {
    /**
     * 新建
     */
    BLANK("新建"),
    /**
     * PENDING="待审核"
     */
    PENDING("待审核"),
    /**
     * APPROVE="审核通过"
     */
    APPROVE("审核通过"),
    /**
     * DISAPPROVE="审核不通过"
     */
    DISAPPROVE("审核不通过"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static AuditStateEnum match(String val, AuditStateEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static AuditStateEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(AuditStateEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "BLANK,PENDING,APPROVE,DISAPPROVE", example = "PENDING")
    public String getCode() {
        return this.name();
    }


}
